<template>
    <div>
        <Row style="line-height: 35px;">
            <Col span='2'>
                <b>基础信息</b>
            </Col>
            <Col span='9' offset="1">
                <span>一级风险单元：{{InputData.saRiskInfo.riskUnitName}}</span>
            </Col>
            <Col span='9' offset="1">
                <span>二级风险单元：{{InputData.saRiskInfo.riskUnit2}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px" class="detail-background-clor">
            <Col span='9' offset="3">
                <span>三级风险单元：{{InputData.saRiskInfo.riskUnit3}}</span>
            </Col>
            <Col span='9' offset="1">
                <span>四级风险单元：{{InputData.saRiskInfo.riskUnit4}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px">
            <Col span='9' offset="3">
                <span>作业内容：{{InputData.saRiskInfo.workContent}}</span>
            </Col>
            <Col span='9' offset="1">
                <span>风险类别：{{InputData.saRiskInfo.riskTypeName}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px" class="detail-background-clor">
            <Col span='20' offset="3">
                <span>风险识别维度：{{InputData.saRiskInfo.rikDiscernName}}</span>
            </Col>
        </Row>
        <Row style="line-height: 35px">
            <Col span='20' offset="3">
                <span>风险描述：{{InputData.saRiskInfo.riskDesc}}</span>
            </Col>
        </Row>
        <hr style="margin-top: 10px;color: #dcdcdc"/>
        <Row style="line-height: 25px;margin-top: 10px">
            <Col span='2'>
                <b>风险评价</b>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='历史发生概率Q1：' prop="q1">
                    <Select v-model="InputData.q1">
                        <Option v-for="item in q1List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.q1Name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='风险承受能力Q2：' prop="q2">
                    <Select v-model="InputData.q2">
                        <Option v-for="item in q1List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.q2Name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='死亡损失M1：' prop="m1">
                    <Select v-model="InputData.m1">
                        <Option v-for="item in q1List" v-show="item.m1Name!=null" :value="item.id"
                                :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.m1Name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="3">
                <FormItem label='重伤损失M2：' prop="m2">
                    <Select v-model="InputData.m2">
                        <Option v-for="item in q1List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.m2Name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='经济损失E1：' prop="e1">
                    <Select v-model="InputData.e1">
                        <Option v-for="item in q1List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.e1Name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='周边敏感目标影响人数S1：' prop="s1">
                    <Select v-model="InputData.s1">
                        <Option v-for="item in q1List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.s1Name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
        </Row>
        <Row style="line-height: 25px">
            <Col span='6' offset="3">
                <FormItem label='社会关注度S2：' prop="s2">
                    <Select v-model="InputData.s2">
                        <Option v-for="item in q1List" :value="item.id" :label="item.id">
                            <span> {{item.id}}</span>
                            <span style="float:right;color:#ccc"> {{item.s2Name }}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
        </Row>
        <Row style="line-height: 25px;margin-top: 10px">
            <Col span='6' offset="3">
                <span>可能性计算：{{passibleCal}}</span>
            </Col>
            <Col span='6' offset="1">
                <span>严重性计算：{{InputData.severityCal}}</span>
            </Col>
            <Col span='6' offset="1">
                <span>风险等级R：{{InputData.rikRankName}}</span>
            </Col>
        </Row>
        <Row style="line-height: 25px;margin-top: 10px">
            <Col span='6' offset="3">
                <span>可能性值：{{passibleCal}}</span>
            </Col>
            <Col span='6' offset="1">
                <span>严重性值：{{InputData.severityVal}}</span>
            </Col>
            <Col span='6' offset="1">
                        <span>风险警示色：
                            <span v-if="InputData.rikColor=='红'" style="color: red">{{InputData.rikColor}}</span>
                            <span v-else-if="InputData.rikColor=='橙'"
                                  style="color: orange">{{InputData.rikColor}}</span>
                            <span v-else-if="InputData.rikColor=='黄'"
                                  style="color: #FDD835">{{InputData.rikColor}}</span>
                            <span v-else-if="InputData.rikColor=='蓝'" style="color: blue">{{InputData.rikColor}}</span>
                            <span v-else style="color: white">{{InputData.rikColor}}</span>
                        </span>
            </Col>
        </Row>
        <hr style="margin-top: 10px;color: #dcdcdc"/>
        <Row style="line-height: 25px;margin-top: 10px">
            <Col span='2'>
                <b>风险管控</b>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='风险防范措施(技术、管理、教育)：' prop="manageMeasure">
                    <Input v-model="InputData.saRiskManage.manageMeasure"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='应急措施(救治、处置)：' prop="emerMearsure">
                    <Input v-model="InputData.saRiskManage.emerMearsure"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='责任部门：' prop="dutyOrgName"><!-- dutyOrgId -->
                    <Input v-model="InputData.saRiskManage.dutyOrgName"/>
                  <!--  <cascaderDom ref="childOrg" @setOrgInfo="setOrgId" @setOrgname="setOrgName"
                                 :currentOrgId="InputData.saRiskManage.dutyOrgId"
                                 :currentOrgName="InputData.saRiskManage.dutyOrgName"
                                 :orgTree="true"></cascaderDom>-->
                </FormItem>
            </Col>
            <Col span='6' offset="3">
                <FormItem label='责任人：' prop="dutyPersonName"><!--dutyPersonId-->
                  <!--  <cascaderDom ref="childUser1" @setOrgInfo="setUserId" @setOrgname="setUserName"
                                 :currentOrgId="InputData.saRiskManage.dutyPersonId"
                                 :currentOrgName="InputData.saRiskManage.dutyPersonName">
                    </cascaderDom>-->
                    <Input v-model="InputData.saRiskManage.dutyPersonName"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='关注层面：' prop="focusAspect">
                    <Input v-model="InputData.saRiskManage.focusAspect"/>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='关注周期：' prop="focusCycle">
                    <Input v-model="InputData.saRiskManage.focusCycle"/>
                </FormItem>
            </Col>
            <Col span='6' offset="3">
                <FormItem label='审核人：' prop="checker">
                    <!--<Input v-model="InputData.saRiskAssess.checker"/>-->
                  <!--  <cascaderDom ref="childUser" @setOrgInfo="setUserId1" @setOrgname="setUserName1"
                                 :currentOrgId="InputData.saRiskAssess.checker"
                                 :currentOrgName="InputData.saRiskAssess.checkerName">

                    </cascaderDom>-->
                    <Select
                            v-model="InputData.saRiskAssess.checker"
                            filterable
                            :remote-method="remoteMethod1"
                            :loading="loading1">
                        <Option v-for="(option, index) in options1" :value="option.userId"
                                :label="option.userName" :key="index">
                            <span>{{option.userName}}</span>
                            <span style="float:right;color:#ccc">{{option.orgInfo.orgName}}</span>
                        </Option>
                    </Select>
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='录入人：'>
                    {{InputData.saRiskManage.recorder}}
                </FormItem>
            </Col>
            <Col span='6' offset="1">
                <FormItem label='录入时间：'>
                    {{InputData.saRiskManage.recordeTime}}
                </FormItem>
            </Col>
        </Row>
    </div>
</template>

<script>
    import cascaderDom from '../../../../components/cascader-dom.vue';
    import {Api} from '../../../../api/index.js'
    import {sessionStorage} from '../../../../common/cacheUtils.js';
    export default {
        components: {cascaderDom},
        props: ['InputData','model1','options1'],
        name: "workProcessRiskApproval",
        data(){
            return{
                q1List: [
                    {
                        id: 1,
                        q1Name: '基本不可能(过去从未发生)',
                        q2Name: '承受力很强',
                        m1Name: '小(0人)',
                        m2Name: '很小(小于等于1人)',
                        e1Name: '很小(小于10万元)',
                        s1Name: '很小(影响小于10人)',
                        s2Name: '很小(本区关注1(含)天至7天或本市关注1天内)',
                    },
                    {
                        id: 2,
                        q1Name: '较不可能(过去10年以上发生1次)',
                        q2Name: '承受力强',
                        m2Name: '小(2人)',
                        e1Name: '小(10万元至50万元)',
                        s1Name: '小(影响在10至99人之间)',
                        s2Name: '小(本区关注7(含)天至30天或本市关注1(含)天至7天或国内关注1天内)',
                    },
                    {
                        id: 3,
                        q1Name: '可能(过去10年发生1次)',
                        q2Name: '承受力一般',
                        m1Name: '一般(1人)',
                        m2Name: '一般(3至5人)',
                        e1Name: '一般(50万元至100万元)',
                        s1Name: '一般(影响在100至499人之间)',
                        s2Name: '一般(本区关注30(含)天以上或本市关注7(含)天至30天或国内关注1(含)天至7天或国际关注1天内)',
                    },
                    {
                        id: 4,
                        q1Name: '较可能(过去5年发生1次)',
                        q2Name: '承受力弱',
                        m1Name: '大(2人)',
                        m2Name: '大(6至8人)',
                        e1Name: '大(100万元至500万元)',
                        s1Name: '大(影响在500至999人之间)',
                        s2Name: '大(本市关注30(含)天以上或国内关注7(含)天至30天或国际关注1(含)天至7天)',
                    },
                    {
                        id: 5,
                        q1Name: '很可能(过去2年发生1次以上)',
                        q2Name: '承受力很弱',
                        m1Name: '很大(大于等于3人)',
                        m2Name: '很大(大于等于9人)',
                        e1Name: '很大(大于等于500万元)',
                        s1Name: '很大(影响大于等于1000人)',
                        s2Name: '很大(国内关注30(含)天以上或国际关注7(含)天以上)',
                    }
                ],
                loading1:false
            }
        },
        watch: {
            "model1": function (qw, er) {
                if (qw && this.model1) {
                    setTimeout(() => {
                        this.$refs.childOrg.setCurrentOrg();
                        this.$refs.childUser.setCurrentOrg();
                        this.$refs.childUser1.setCurrentOrg();
                    }, 100);
                } else {
                    this.$refs.childOrg.resetCurrentOrg();
                    this.$refs.childUser.resetCurrentOrg();
                    this.$refs.childUser1.resetCurrentOrg();
                }
            },
        },
        computed: {
            passibleCal: function () {
                let r5 = 0 //可能性计算
                let s5 = 0 //严重性计算
                let rikRan = ' '
                let rikColor = ' '
                if (this.InputData.q1 > 0 && this.InputData.q2 > 0) {
                    r5 = Math.ceil(this.NumberAdd(this.InputData.q1, this.InputData.q2) / 2)
                }
                if (this.InputData.m1 > 0 && this.InputData.m2 > 0 && this.InputData.e1 > 0 && this.InputData.s1 > 0 && this.InputData.s2 > 0) {
                    s5 = Math.ceil((this.InputData.m1 + this.InputData.m2 + this.InputData.e1 + this.InputData.s1 + this.InputData.s2) / 5)
                }
                this.InputData.severityCal = s5 > 0 ? s5 : ' ';
                this.InputData.severityVal = s5 > 0 ? s5 : ' ';

                this.InputData.passibleCal = r5 > 0 ? r5 : ' ';
                this.InputData.passibleVal = r5 > 0 ? r5 : ' ';
                if (s5 == 0 || r5 == 0) {
                    rikRan = ' '
                }else if ((r5 > 2 && s5 == 5) || (r5 == 5 && s5 == 4)) {
                    rikRan = '重大'
                }else if ((r5 == 2 && s5 == 5) || ((r5 == 3 || r5 == 4) && s5 == 4) || (r5 > 3 && s5 == 3) || (s5 == 2 && r5 == 5)) {
                    rikRan = '较大'
                }else if ((r5 == 1 && s5 > 3) || ((s5 == 3 || s5 == 4) && r5 == 2) || ((s5 == 2 || s5 == 3) && r5 == 3) || (s5 == 2 && r5 == 4) || (s5 == 1 && r5 > 3)) {
                    rikRan = '一般'
                }else {
                    rikRan = '低'
                }
                rikColor = rikRan == '重大' ? '红' : rikRan == '较大' ? '橙' : rikRan == '一般' ? '黄' : rikRan == '低' ? '蓝' : ' '
                this.InputData.rikRankName = rikRan;
                this.InputData.rikColor = rikColor
                this.InputData.saRiskAssess.rikColor = rikColor
                return this.InputData.passibleCal;
            }
        },
        methods:{
            remoteMethod1(query) {
                if (query !== '') {
                    clearTimeout(this.remoteMethod1.timer);
                    this.remoteMethod1.timer = setTimeout(() => {
                        this.options1.splice(0, this.options1.length);
                        this.loading1 = true;
                        let data = {
                            userName: query,
                            orgId: sessionStorage('userId').getObject('userId').orgInfo.parentId
                        };
                        this.$http.get(Api.queryUserByUserName, {params: data}).then((res) => {
                            this.loading1 = false;
                            res.data.data.forEach(item => {
                                this.options1.push(item);
                            })

                        }).catch(e => {
                            this.loading1 = false;
                        })
                    }, 200);
                } else {
                    this.options1 = [];
                }
            },
            setOrgId(data) {
                this.InputData.saRiskManage.dutyOrgId = data[data.length - 1];
            },
            setOrgName(data) {
                this.InputData.saRiskManage.dutyOrgName = data;
            },
            setUserName(data) {
                this.InputData.saRiskManage.dutyPersonName = data;
            },
            setUserId(data) {
                this.InputData.saRiskManage.dutyPersonId = data[data.length - 1];
            },
            setUserName1(data) {
                this.InputData.saRiskAssess.checkerName = data;
            },
            setUserId1(data) {
                this.InputData.saRiskAssess.checker = data[data.length - 1];
            },
        }
    }
</script>

<style scoped>

</style>